package io.renren.controller;

import io.renren.common.entity.XlsUsersBankcardsEntity;
import io.renren.service.XlsUsersBankcardsService;
import io.renren.utils.AppResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户的银行卡表
 *
 * @author Mark sunlightcs@gmail.com
 * @since 1.0.0 2020-04-12
 */
@RestController
@RequestMapping("/api/xlsusersbankcards")
@Api(tags="用户的银行卡表")
public class XlsUsersBankcardsController {
    @Autowired
    private XlsUsersBankcardsService xlsUsersBankcardsService;

    /**
     * 用户点击银行卡添加(去往添加银行卡页面)不是真的添加
     */

    @PostMapping( "/toAddBankcards")
    @ApiOperation("用户点击银行卡(去往添加银行卡页面)认证是否有真实姓名")
    public AppResult toAddBankcards(Long userId){
        return xlsUsersBankcardsService.toAddBankcards(userId);
    }


    /**
     * 用户的银行卡添加
     */
    @PostMapping( "/agreeconfirm")
    @ApiOperation("用户的银行卡")
    public AppResult agreeconfirm (XlsUsersBankcardsEntity usersBankcards, String realName, String cardId ){
        return xlsUsersBankcardsService.agreeconfirm(usersBankcards,realName,cardId);
    }

    /**
     * 查询用户的银行卡列表
     */
    @PostMapping("/list")
    @ApiOperation("查询用户的银行卡列表")
    public AppResult list(XlsUsersBankcardsEntity usersBankcards){
        return xlsUsersBankcardsService.selectBankCartsList(usersBankcards);
    }

    /**
     * 解除银行卡
     */
    @PostMapping("/unbind")
    @ApiOperation("解除银行卡")
    public AppResult unbind(Long bankCardId){
        return xlsUsersBankcardsService.unbind(bankCardId);
    }


    /**
     * 根据银行卡Id获取银行卡
     * @param bankCardId
     * @return
     */
    @GetMapping("/getBankById")
    @ApiOperation("根据银行卡Id获取银行卡")
    public AppResult getBankById(Long bankCardId){
        return xlsUsersBankcardsService.getBankById(bankCardId);
    }

}